#include <iostream>
#include <cmath>
using namespace std;
int main(){
    int a, b;
    double sum=0, sumer=0;
    cin >> a >> b;
    double A[a][b] = {};
    for (size_t i=0; i<a; i++){
        for (size_t j=0; j<b; j++){
            cin >> A[i][j];
        }
    }

    for (size_t i=0; i<b; i++){
        for (size_t j=0; j<a; j++){
            sum += A[j][i];
        }
        cout << (int) ( (sum / a) + 0.5);
        cout << " ";
        sumer += sum;
        sum = 0;
    }
    cout << endl << lround(sumer / (a*b)) << endl;
}
